//
//    CommentListModel.swift
//
//    Create by 松 松 on 3/6/2019
//    Copyright © 2019. All rights reserved.
//    Model file generated using JSONExport: https://github.com/Ahmed-Ali/JSONExport

import Foundation


open class CommentListModel : NSObject, NSCoding, SSMap{

    public var appCode : String?
    public var badNum : Int?
    public var cmComment : CmComment?
    public var commentContent : String?
    public var commentDate : Int?
    public var commentReplyNum : Int?
    public var commentSate : Int?
    public var delFlag : Int?
    public var formUserId : String?
    public var fromUserHead : String?
    public var fromUserName : String?
    public var id : String?
    public var isLike : Bool?
    public var likeNum : Int?
    public var mainTypeCode : String?
    public var toItemCode : String?

    public func getTime() -> String{
        if commentDate == nil{
            return ""
        }
        let date = Date(timeIntervalSince1970: Double(commentDate!/1000))
        return date.timeAgoSinceDate()
    }

    public override init() {

    }

    /**
     * Instantiate the instance using the passed dictionary values to set the properties values
     */
    required public init(fromDictionary dictionary: [String:Any]){
        appCode = dictionary["appCode"] as? String
        badNum = dictionary["badNum"] as? Int
        if let cmCommentData = dictionary["cmComment"] as? [String:Any]{
            cmComment = CmComment(fromDictionary: cmCommentData)
        }
        commentContent = dictionary["commentContent"] as? String
        commentDate = dictionary["commentDate"] as? Int
        commentReplyNum = dictionary["commentReplyNum"] as? Int
        commentSate = dictionary["commentSate"] as? Int
        delFlag = dictionary["delFlag"] as? Int
        formUserId = dictionary["formUserId"] as? String
        fromUserHead = dictionary["fromUserHead"] as? String
        fromUserName = dictionary["fromUserName"] as? String
        id = dictionary["id"] as? String
        isLike = dictionary["isLike"] as? Bool
        likeNum = dictionary["likeNum"] as? Int
        mainTypeCode = dictionary["mainTypeCode"] as? String
        toItemCode = dictionary["toItemCode"] as? String
    }

    /**
     * Returns all the available property values in the form of [String:Any] object where the key is the approperiate json key and the value is the value of the corresponding property
     */
    public func toDictionary() -> [String:Any]
    {
        var dictionary = [String:Any]()
        if appCode != nil{
            dictionary["appCode"] = appCode
        }
        if badNum != nil{
            dictionary["badNum"] = badNum
        }
        if cmComment != nil{
            dictionary["cmComment"] = cmComment?.toDictionary()
        }
        if commentContent != nil{
            dictionary["commentContent"] = commentContent
        }
        if commentDate != nil{
            dictionary["commentDate"] = commentDate
        }
        if commentReplyNum != nil{
            dictionary["commentReplyNum"] = commentReplyNum
        }
        if commentSate != nil{
            dictionary["commentSate"] = commentSate
        }
        if delFlag != nil{
            dictionary["delFlag"] = delFlag
        }
        if formUserId != nil{
            dictionary["formUserId"] = formUserId
        }
        if fromUserHead != nil{
            dictionary["fromUserHead"] = fromUserHead
        }
        if fromUserName != nil{
            dictionary["fromUserName"] = fromUserName
        }
        if id != nil{
            dictionary["id"] = id
        }
        if isLike != nil{
            dictionary["isLike"] = isLike
        }
        if likeNum != nil{
            dictionary["likeNum"] = likeNum
        }
        if mainTypeCode != nil{
            dictionary["mainTypeCode"] = mainTypeCode
        }
        if toItemCode != nil{
            dictionary["toItemCode"] = toItemCode
        }
        return dictionary
    }

    /**
     * NSCoding required initializer.
     * Fills the data from the passed decoder
     */
    @objc required public init(coder aDecoder: NSCoder)
    {
        appCode = aDecoder.decodeObject(forKey: "appCode") as? String
        badNum = aDecoder.decodeObject(forKey: "badNum") as? Int
        cmComment = aDecoder.decodeObject(forKey: "cmComment") as? CmComment
        commentContent = aDecoder.decodeObject(forKey: "commentContent") as? String
        commentDate = aDecoder.decodeObject(forKey: "commentDate") as? Int
        commentReplyNum = aDecoder.decodeObject(forKey: "commentReplyNum") as? Int
        commentSate = aDecoder.decodeObject(forKey: "commentSate") as? Int
        delFlag = aDecoder.decodeObject(forKey: "delFlag") as? Int
        formUserId = aDecoder.decodeObject(forKey: "formUserId") as? String
        fromUserHead = aDecoder.decodeObject(forKey: "fromUserHead") as? String
        fromUserName = aDecoder.decodeObject(forKey: "fromUserName") as? String
        id = aDecoder.decodeObject(forKey: "id") as? String
        isLike = aDecoder.decodeObject(forKey: "isLike") as? Bool
        likeNum = aDecoder.decodeObject(forKey: "likeNum") as? Int
        mainTypeCode = aDecoder.decodeObject(forKey: "mainTypeCode") as? String
        toItemCode = aDecoder.decodeObject(forKey: "toItemCode") as? String

    }

    /**
     * NSCoding required method.
     * Encodes mode properties into the decoder
     */
    @objc public func encode(with aCoder: NSCoder)
    {
        if appCode != nil{
            aCoder.encode(appCode, forKey: "appCode")
        }
        if badNum != nil{
            aCoder.encode(badNum, forKey: "badNum")
        }
        if cmComment != nil{
            aCoder.encode(cmComment, forKey: "cmComment")
        }
        if commentContent != nil{
            aCoder.encode(commentContent, forKey: "commentContent")
        }
        if commentDate != nil{
            aCoder.encode(commentDate, forKey: "commentDate")
        }
        if commentReplyNum != nil{
            aCoder.encode(commentReplyNum, forKey: "commentReplyNum")
        }
        if commentSate != nil{
            aCoder.encode(commentSate, forKey: "commentSate")
        }
        if delFlag != nil{
            aCoder.encode(delFlag, forKey: "delFlag")
        }
        if formUserId != nil{
            aCoder.encode(formUserId, forKey: "formUserId")
        }
        if fromUserHead != nil{
            aCoder.encode(fromUserHead, forKey: "fromUserHead")
        }
        if fromUserName != nil{
            aCoder.encode(fromUserName, forKey: "fromUserName")
        }
        if id != nil{
            aCoder.encode(id, forKey: "id")
        }
        if isLike != nil{
            aCoder.encode(isLike, forKey: "isLike")
        }
        if likeNum != nil{
            aCoder.encode(likeNum, forKey: "likeNum")
        }
        if mainTypeCode != nil{
            aCoder.encode(mainTypeCode, forKey: "mainTypeCode")
        }
        if toItemCode != nil{
            aCoder.encode(toItemCode, forKey: "toItemCode")
        }

    }

}
